
/*
 * Include Files
 *
 */
#if defined(MATLAB_MEX_FILE)
#include "tmwtypes.h"
#include "simstruc_types.h"
#else
#define SIMPLIFIED_RTWTYPES_COMPATIBILITY
#include "rtwtypes.h"
#undef SIMPLIFIED_RTWTYPES_COMPATIBILITY
#endif



/* %%%-SFUNWIZ_wrapper_includes_Changes_BEGIN --- EDIT HERE TO _END */
#include <math.h>
#define  rampDelayMax   1
static float targetValue;
static float setPointValue;
static int rampDelayCnt;
/* %%%-SFUNWIZ_wrapper_includes_Changes_END --- EDIT HERE TO _BEGIN */
#define u_width 1
#define u_1_width 1
#define y_width 1

/*
 * Create external references here.  
 *
 */
/* %%%-SFUNWIZ_wrapper_externs_Changes_BEGIN --- EDIT HERE TO _END */
 
/* %%%-SFUNWIZ_wrapper_externs_Changes_END --- EDIT HERE TO _BEGIN */

/*
 * Output function
 *
 */
void ramp_controller_Outputs_wrapper(const real32_T *freq,
			const uint32_T *cnt,
			real32_T *angle)
{
/* %%%-SFUNWIZ_wrapper_Outputs_Changes_BEGIN --- EDIT HERE TO _END */
if(*cnt > 3000)
{
    targetValue = *freq;
    float tmp = targetValue - setPointValue;
    if(fabsf(tmp) >= (0.00005f * targetValue))
    {
        rampDelayCnt++;
        if((rampDelayCnt) >= rampDelayMax)
        {
            if(targetValue >= setPointValue)
            {
                setPointValue += (0.00005f * targetValue);
            }

            else
            {
                setPointValue -= (0.00005f * targetValue);
            }

            rampDelayCnt = 0;
        }
    }
    else
    {
        setPointValue = targetValue;
    }

    *angle += setPointValue * 0.0001f;

    if(*angle > 1.0f)
    {
        *angle = 0.0f;
    }
}
else
{
    *angle = 0.0f;
}
/* %%%-SFUNWIZ_wrapper_Outputs_Changes_END --- EDIT HERE TO _BEGIN */
}


